﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Taobao.Tools2.Domain.EntityFramework.Mappings
{
    #region  DerivedModelDiscriminatorRequireCondition<T, TValue>
    public class DerivedModelDiscriminatorRequireCondition<T, TValue> : IDerivedModelRequireCondition<T>
        where TValue : struct
        where T : class
    {
        public DerivedModelDiscriminatorRequireCondition(string discriminator, TValue discriminatorValue)
        {
            Discriminator = discriminator;
            DiscriminatorValue = discriminatorValue;
        }

        public string Discriminator { get; set; }
        public TValue DiscriminatorValue { get; set; }

        public void Required(System.Data.Entity.ModelConfiguration.Configuration.EntityMappingConfiguration<T> entityMappingConfiguration)
        {
            entityMappingConfiguration.Requires(Discriminator).HasValue<TValue>(DiscriminatorValue);
        }
    }
    #endregion    
}
